package cn.ljh.student.service.impl;
import cn.ljh.student.dao.StudentMapper;
import cn.ljh.student.pojo.Student;
import cn.ljh.student.service.StudentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class StudentServiceImpl implements StudentService {

    @Resource
    private StudentMapper studentMapper;

    public Student getStudentById(String id)throws Exception{
        return studentMapper.getStudentById(id);
    }

    public List<Student>	getStudentListByMap(Map<String,Object> param)throws Exception{
        return studentMapper.getStudentListByMap(param);
    }

    public Integer getStudentCountByMap(Map<String,Object> param)throws Exception{
        return studentMapper.getStudentCountByMap(param);
    }

    public Integer qdtxAddStudent(Student student)throws Exception{
            //student.setCreatedTime(new Date());
            return studentMapper.insertStudent(student);
    }

    public Integer qdtxModifyStudent(Student student)throws Exception{
        //student.setUpdatedTime(new Date());
        return studentMapper.updateStudent(student);
    }

    public Integer qdtxDeleteStudentById(String id)throws Exception{
        return studentMapper.deleteStudentById(id);
    }

    public Integer qdtxBatchDeleteStudent(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return studentMapper.batchDeleteStudent(param);
    }


}
